﻿<!--#include file="Errc.asp"-->
<%
'''这是核心入口类(单文件)
Class AshapoClass
''''''''''''''''''''''''''''''''''''''''系统环境相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'RegExp对象
	Private s_regex
	'''运行代码的前修饰符,一般为变量定义
	Private s_vcodepre
	'''include的文件及代码(头部)遵循规定：先开始后结束，后开始先结束
	Private s_inccodepre
	'''include的代码(底部)
	Private s_inccodefix
	'''双引号替代符
	Private s_dqmarkstr
	'''单引号替代符
	Private s_sqmarkstr
	'''Literal标签收集器,Literal标签收集器key前缀,收集个数
	Private s_collector, s_collectorPre, s_colli
	'''页面跳转标题,提示信息,跳转等待时间(秒),跳转页面地址
	Private s_msgTitle, s_message, s_waitSecond, s_jumpUrl
	
	'内部使用Fso名称
	Private s_fso
	'FSO组件名
	Private s_fsoName
	'星号替换字符、问号替换字符(这两个字符串要足够复杂防止出现路径被替换), BOM头
	Private s_xingStr, s_wenStr
	
	'''Ecore/Use/Extends的析构触发代码段,编译的一致顺序是先进后出
	Private s_codefix
	
	'''当前G/M/A/T
	Private s_nowG, s_nowM, s_nowA, s_nowT
	
	'''可运行缓存文件路径/data/_cache/_run/home/index_index.asp
	Private s_vcp
	'''action类文件路径/app/Action/home/indexAction.class.asp
	Private s_vfp
	'''处理后的缓存action类文件路径/data/_cache/_action/home/indexAction.class.asp
	Private s_ccp
	'''模板路径,用于Tpl.Display过程/app/Tpl/default/home/index/index.html
	Private s_vtp
	'''进行的数据库查询次数
	Public DbQueryTimes
	
	'''构造
	Private Sub Class_Initialize()
		'文件系统构造
		s_fsoName 	= C_FsoName
		Set s_fso 	= Server.CreateObject(s_fsoName)
		s_xingStr = "[.$.[a.s.h.a.p.o.s.t.a.r].#.]"
		s_wenStr = "[.$.[a.s.h.a.p.o.q.u.e.s].#.]"
		'模板解析构造
		s_vcodepre = ""
		s_inccodepre = ""
		s_inccodefix = ""
		s_dqmarkstr = "~"
		s_sqmarkstr = "`"
		Set s_regex = New RegExp
		s_regex.Global = True
		s_regex.IgnoreCase = True
		s_regex.Multiline = False
		's_collectorPre不能包含正则元字符,且不能与模板中的任何字符串相同
		s_collectorPre = "%ashapocoll%"
		s_colli = 0
		Set s_collector = Server.CreateObject(C_DicName)
		s_msgTitle = ""
		s_message = ""
		s_waitSecond = 3
		s_jumpUrl = ""
		s_codefix = ""
		'获取GMAT信息
		s_nowG = G("g:s:" & C_DefGroup)
		s_nowM = G("m:s:" & C_DefModule)
		s_nowA = G("a:s:" & C_DefAction)
		s_nowT = C_DefTplName
		s_vcp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_run/" & s_nowG & "/" & s_nowM & C_CacheFit & s_nowA & ".asp"
		DbQueryTimes = 0
	End Sub
	
	'''析构
	Private Sub Class_Terminate()
		'在这里进行Ecore/Use/Extends的析构函数
		If s_codefix <> "" Then
			ExecuteGlobal(s_codefix)
		End If
		'模板解析析构
		Set s_regex = Nothing
		Set s_collector = Nothing
		'文件系统析构
		Set s_fso = Nothing
	End Sub
	
	'''获取系统设置(废弃)
	'Config("Debug") = IfHas(G_Debug,C_Debug)
	'p_c:去掉前缀的设置名称
	Public Function Config(Byval p_c)
		Config = Eval("IfHas(G_" & p_c & ", C_" & p_c& ")")
	End Function
	
	'''判断类代码中是否包含指定的公有函数
	'p_f:函数名称
	'p_s:代码段
	Private Function hasFunSub_(Byval p_f, Byval p_s)
		s_regex.Pattern = "[Public]?[\s]*[Sub|Function]{1}[\s]*[\[]?" & p_f & "[\]]?[\s]*\([^\)]*\)"
		If s_regex.Test(p_s) Then
			hasFunSub_ = True
		Else
			hasFunSub_ = False
		End If
	End Function
	
''''''''''''''''''''''''''''''''''''''''------------'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''文件系统相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'''获取实际路径MapPath(不支持通配符)
	'p_p:路径
	Private Function absPath_(Byval p_p)
		On Error Resume Next
		If CStr(p_p) = "" Then
			absPath_ = "" : Exit Function
		End If
		If Mid(p_p,2,1)<>":" Then
			p_p = Server.MapPath(p_p)
		End If
		If Right(p_p,1) = "\" Then
			p_p = Left(p_p,Len(p_p)-1)
		End If
		absPath_ = p_p
		If Err.Number<>0 Then
			Response.Write(p_p)
			Reponse.End()
		End If
		Err.Clear()
	End Function

	'''判断文件是否存在
	'p_p:文件路径
	Private Function isFile_(Byval p_p)
		p_p = absPath_(p_p) : isFile_ = False
		If s_fso.FileExists(p_p) Then
			isFile_ = True
		End If
	End Function
	
	'''判断服务器上的文件夹是否存在
	'p_p:文件夹路径
	Private Function isFolder_(Byval p_p)
		p_p = absPath_(p_p) : isFolder_ = False
		If s_fso.FolderExists(p_p) Then
			isFolder_ = True
		End If
	End Function
	
	'''读取服务器端文件内容
	'p_p:文件路径
	Private Function readFile_(Byval p_p)
		Dim t_s, t_t
		p_p = absPath_(p_p)
		If isFile_(p_p) Then
			Set t_s = Server.CreateObject("ADODB.Stream")
			With t_s
				.Type = 2
				.Mode = 3
				.Open
				.LoadFromFile p_p
				.Charset = "UTF-8"
				.Position = 2
				t_t = .ReadText
				.Close
			End With
			Set t_s = Nothing
			If RegTest(t_t,"^\uFEFF") Then
				t_t = RegReplace(t_t,"^\uFEFF","")
			End If
		Else
			t_t = ""
			'收集错误,Log信息收集
			Errc.Raise(1)
		End If
		readFile_ = t_t
	End Function
	
	'''在服务器上创建文件夹
	'p_p:文件夹路径
	Private Function createFolder_(Byval p_p)
		'On Error Resume Next
		Dim t_p, t_ap, t_i
		createFolder_ = True
		p_p = absPath_(p_p)
		t_ap = Split(p_p,"\") : t_p = ""
		For t_i = 0 To Ubound(t_ap)
			t_p = t_p & t_ap(t_i) & "\"
			If Instr(t_p, absPath_("/") & "\")>0 Then
				If Not isFolder_(t_p) And t_i>0 Then
					s_fso.CreateFolder(t_p)
				End If
			End If
		Next
		If Err.Number<>0 Then
			createFolder_ = False
			'收集错误,Log信息收集
			Errc.Raise(2)
		End If
		Err.Clear()
	End Function
	
	'''在服务器端创建文件并写入内容
	'p_p:文件路径
	'p_c:写入内容
	'p_b:写入BOM头
	Private Function createFile_(Byval p_p, Byval p_c, Byval p_b)
		On Error Resume Next
		Dim t_sm
		p_p = absPath_(p_p)
		createFile_ = createFolder_(Left(p_p,InstrRev(p_p,"\")-1))
		If createFile_ Then
			Set t_sm = Server.CreateObject("ADODB.Stream")
			If p_b=1 Or p_b=True Then
				With t_sm
					.Type = 2
					.Open
					.Charset = "UTF-8"
					.Position = t_sm.Size
					.WriteText = p_c
					.SaveToFile p_p, 2
					.Close
				End With
			Else
				With t_sm
					.Type = 2
					.Mode = 3
					.Charset = "UTF-8"
					.Open
					.Writetext(p_c)
					.Position = 3
				End With
				Dim t_ns : Set t_ns = Server.CreateObject("ADODB.Stream")   
				With t_ns   
					.Mode = 3   
					.Type = 1   
					.Open()   
				End With 
				t_sm.CopyTo(t_ns)   
				t_ns.SaveToFile p_p, 2
				t_sm.Flush
				t_sm.Close
				Set t_ns = Nothing
			End If
			Set t_sm = Nothing
		End If
		If Err.Number<>0 Then
			createFile_ = False
			'收集错误,Log信息收集
			Errc.Raise(4)
		End If
		Err.Clear()
	End Function
	
	'''列出服务器上指定目录下所有的文件或文件夹
	'p_p:目录路径
	'p_t:指定类型(文件或文件夹或全部)
	Private Function dirList_(Byval p_p, Byval p_t)
		On Error Resume Next
		Dim t_f, t_fs, t_k, t_a(), t_i, t_l
		p_p = absPath_(p_p) : t_i = 0
		Select Case LCase(p_t)
		Case "1","file"
			t_l = 1
		Case "2","folder"
			t_l = 2
		Case Else
			t_l = 0
		End Select
		Set t_f = s_fso.GetFolder(p_p)
		If t_l = 0 Or t_l = 2 Then
			Set t_fs = t_f.SubFolders
			ReDim Preserve t_a(2, t_fs.Count-1)
			For Each t_k In t_fs
				t_a(0,t_i) = t_k.Name
				t_a(1,t_i) = t_k.DateLastModified
				t_a(2,t_i) = t_k.Type
				t_i = t_i + 1
			Next
		End If
		If t_l = 0 Or t_l = 1 Then
			Set t_fs = t_f.Files
			ReDim Preserve t_a(2, t_fs.Count+t_i-1)
			For Each t_k In t_fs
				t_a(0,t_i) = t_k.Name
				t_a(1,t_i) = t_k.DateLastModified
				t_a(2,t_i) = t_k.Type
				t_i = t_i + 1
			Next
		End If
		Set t_fs = Nothing
		Set t_f = Nothing
		dirList_ = t_a
		If Err.Number<>0 Then
			'收集错误,Log信息收集
			Errc.Raise(5)
		End If
		Err.Clear()
	End Function
	
	'''获取文件名(不含后缀)
	'p_f文件名(可以包含路径)
	Private Function nameOfFile_(Byval p_f)
		Dim t_re
		If IsN(p_f) Then
			nameOfFile_ = "" : Exit Function
		End If
		p_f = Replace(p_f,"\", "/")
		If Right(p_f,1) = "/" Then
			t_re = Split(p_f, "/")
			nameOfFile_ = IIF(p_t=0, t_re(Ubound(t_re)-1),"")
			Exit Function
		ElseIf Instr(p_f,"/")>0 Then
			t_re = Split(p_f,"/")(Ubound(Split(p_f,"/")))
		Else
			t_re = p_f
		End If
		If Instr(t_re,".")>0 Then
			nameOfFile_ = Left(t_re,InstrRev(t_re,".")-1)
		Else
			nameOfFile_ = t_re
		End If
	End Function
	
''''''''''''''''''''''''''''''''''''''''------------'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''模板解析相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	
	'''设置双引号替换字符
	'不能使用$和常用字符，不能与已有字符串发生冲突
	'考虑废弃
	'p_s:用作双引号替代的字符
	Public Property Let DqMarkStr(Byval p_s)
		s_dqmarkstr = p_s
	End Property

	'''设置单引号替换字符
	'不能使用$和常用字符，不能与已有字符串发生冲突
	'考虑废弃
	'p_s:用作单引号替代的字符
	Public Property Let SqMarkStr(Byval p_s)
		s_sqmarkstr = p_s
	End Property
	
	'''设置页面跳转标题
	'p_t:标题字符串
	Public Property Let MsgTitle(Byval p_t)
		s_msgTitle = p_t
	End Property
	
	'''设置页面跳转提示信息
	'p_m:提示信息字符串
	Public Property Let Message(Byval p_m)
		s_message = p_m
	End Property
	
	'''设置页面跳转等待时间(秒)
	'p_s:等待的秒数(数字)
	Public Property Let WaitSecond(Byval p_s)
		s_waitSecond = p_s
	End Property
	
	'''设置页面跳转页面地址
	'p_u:跳转的链接
	Public Property Let JumpUrl(Byval p_u)
		s_jumpUrl = p_u
	End Property
	
	'''根据整个xml节点属性字符串获取相关属性值
	'p_s:整个xml节点的字符串
	'p_a:属性名称
	'p_d:为空时的默认值
	Private Function getAttr_(Byval p_s, Byval p_a, Byval p_d)
		s_regex.Pattern = "[\s\S]*[\s]*" & p_a & "[\s]*=[\s]*['|" & Chr(34) & "]?[\s]*([^'" & Chr(34) & "]*)[\s]*['|" & Chr(34) & "]?"
		Dim t_c : Set t_c = s_regex.Execute(p_s)
		If t_c.Count = 1 Then
			getAttr_ = t_c(0).SubMatches(0)
		Else
			getAttr_ = ""
		End If
		If getAttr_ = "" Then
			getAttr_ = p_d
		End If
		'还原双引号和单引号
		getAttr_ = Replace(getAttr_, s_dqmarkstr, """")
		getAttr_ = Replace(getAttr_, s_sqmarkstr, "'")
		Set t_c = Nothing
	End Function
	
	'''将$var转化为var,即去掉前面的$(如第一个字符不是$则原样返回)
	'p_v:要转换的字符串
	Private Function toVar_(Byval p_v)
		If Left(p_v,1) = "$" Then
			toVar_ = Right(p_v, Len(p_v)-1)
		Else
			toVar_ = p_v
		End If
	End Function
	
	'''收集Literal标签内容
	'解析Literal标签的过程包括收集和恢复两部分
	'仅解析最外层Literal,这样内层Literal也可以原样输出
	'p_s:要解析的模板代码
	Private Function sjLiteral_(Byval p_s)
		s_regex.Pattern = "<literal[^>]*[\s]*>[\s]*[\n]?(((?!<literal(.|\n))(.|\n)(?!literal>))+)<\/literal>[\s]*[\n]?"
		Dim t_r : Set t_r = New RegExp
		t_r.Global = True
		t_r.IgnoreCase = True
		t_r.Multiline = False
		t_r.Pattern = "~" & s_collectorPre & "([\d]?)~"
		Dim t_i, t_v, t_t
		Dim t_c, t_m : Set t_m = s_regex.Execute(p_s)
		For Each t_c In t_m
			't_v = t_c.SubMatches(0)
			t_v = t_c.Value
			'开始收集
			s_colli = s_colli + 1
			'本次匹配字符串内已有之前匹配的Literal标签，则应进行还原
			Set t_t = t_r.Execute(t_v)
			For Each t_i In t_t
				If s_collector.Exists("~" & s_collectorPre & t_i.SubMatches(0) & "~") Then
					t_v = Replace(t_v, "~" & s_collectorPre & t_i.SubMatches(0) & "~", s_collector("~" & s_collectorPre & t_i.SubMatches(0) & "~"))
					s_collector.Remove("~" & s_collectorPre & t_i.SubMatches(0) & "~")
				End If
			Next
			Set t_t = Nothing
			s_collector("~" & s_collectorPre & Cstr(s_colli) & "~") = t_v
			p_s = Replace(p_s, t_c.Value, "~" & s_collectorPre & Cstr(s_colli) & "~")
		Next
		Set t_m = Nothing
		If s_regex.Test(p_s) Then
			sjLiteral_ = sjLiteral_(p_s)
		Else
			sjLiteral_ = p_s
		End If
	End Function
	
	'''恢复Literal标签内容
	'解析Literal标签的过程包括收集和恢复两部分
	'p_s:要解析的模板代码
	Private Function hfLiteral_(Byval p_s)
		Dim t_k, t_s
		If Has(s_collector) Then
			For Each t_k In s_collector
				'剔除最外层的Literal标签
				t_s = s_collector(t_k)
				t_s = Right(t_s, Len(t_s)-InStr(t_s, ">"))
				t_s = Left(t_s, InStrRev(t_s, "<")-1)
				'删除可能出现的换行
				If InStr(t_s, vbcrlf) = 1 Then
					t_s = Replace(t_s,vbcrlf,"",1,1)
				End If
				p_s = Replace(p_s,t_k,t_s)
			Next
		End If
		hfLiteral_ = p_s
	End Function
	
	'''解析Include标签
	'file:文件路径
	'路径分析:
	'1:完整路径，以"/"作为开头
	'2:当前模块模版(read)
	'3:其他模块模板(public:header)
	'4:其他分组模块模板(admin:user:read)
	'5:其他主题分组模块模板,不建议使用(bule:admin:user:read)
	'p_s:要解析的模板代码
	Private Function jxInclude_(Byval p_s)
		s_regex.Pattern = "<include[\s]+([^>]*)[\s]*[\/]?[\s]*>"
		Dim t_mc : Set t_mc = s_regex.Execute(p_s)
		Dim t_ma, t_f, t_t, t_g, t_m, t_a
		Dim t_a1, t_a2, t_a3, t_tp
		t_tp = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/" & s_nowG
		t_tp = t_tp & "/" & s_nowM & "/" & s_nowA & C_TplExtSuf
		t_a = Split(t_tp, "/")
		t_t = t_a(3)
		t_g = t_a(4)
		t_m = t_a(5)
		For Each t_ma In t_mc
			t_f = getAttr_(t_ma.SubMatches(0), "file", "")
			t_f = Replace(t_f, "\", "/")
			If t_f = "" Then
				Errc.Throw(43)
			End If
			If Not Left(t_f,1) = "/" Then
				t_a1 = ParamRev(t_f)
				t_a = t_a1(0)
				If Has(t_a1(1)) Then
					t_a2 = ParamRev(t_a1(1))
					t_m = t_a2(0)
					If Has(t_a2(1)) Then
						t_a3 = ParamRev(t_a2(1))
						t_g = t_a3(0)
						If Has(t_a3(1)) Then
							t_t = t_a3(1)
						End If
					End If
				End If
				t_f = "/" & C_AppFolder & "/" & C_TplFolder & "/" & t_t & "/" & t_g & "/" & t_m & "/" & t_a & C_TplExtSuf
			End If
			If isFile_(t_f) Then
				p_s = Replace(p_s, t_ma.Value, readFile_(t_f))
				'对每个新解析文件都应进行Literal标签收集
				p_s = sjLiteral_(p_s)
			Else
				Errc.Throw(44)
			End If
		Next
		Set t_mc = Nothing
		If s_regex.Test(p_s) Then
			jxInclude_ = jxInclude_(p_s)
		Else
			jxInclude_ = p_s
		End If
	End Function
	
	'''解析ForEach标签
	'''思路是先匹配最内层标签，然后进行递归
	'name:数组或对象名
	'item:循环变量名
	'key:循环增量
	'p_s:要解析的模板代码
	Private Function jxForEach_(Byval p_s)
		s_regex.Pattern = "<foreach[\s]+([^>]*)[\s]*>[\s]*[\n]?(((?!<foreach(.|\n))(.|\n)(?!foreach>))+)<\/foreach>[\s]*[\n]?"
		Dim t_mc : Set t_mc = s_regex.Execute(p_s)
		Dim t_s, t_m, t_item, t_name, t_key
		For Each t_m In t_mc
			t_item = getAttr_(t_m.SubMatches(0), "item", "x")
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			If t_name = "" Then
				Errc.Throw(31)
			End If
			t_key = getAttr_(t_m.SubMatches(0), "key", "i")
			t_s = ""
			t_s = t_s & "<" & Chr(37) & vbcrlf & "Dim " & t_key & " : " & t_key & " = 0" & vbcrlf
			t_s = t_s & "For Each " & t_item & " In " & t_name & vbcrlf
			t_s = t_s & t_key & " = " & t_key & " + 1" & vbcrlf & Chr(37) & ">"
			t_s = t_s & t_m.SubMatches(1)
			t_s = t_s & "<" & Chr(37) & vbcrlf & "Next" & vbcrlf & Chr(37) & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		If s_regex.Test(p_s) Then
			jxForEach_ = jxForEach_(p_s)
		Else
			jxForEach_ = p_s
		End If
	End Function
	
	'''解析For标签
	'name:变量名
	'start:开始增量
	'end:结束增量
	'step:步进增量
	'p_s:要解析的模板代码
	Private Function jxFor_(Byval p_s)
		s_regex.Pattern = "<for[\s]+([^>]*)[\s]*>[\s]*[\n]?(((?!<for(.|\n))(.|\n)(?!for>))+)<\/for>[\s]*[\n]?"
		Dim t_mc : Set t_mc = s_regex.Execute(p_s)
		Dim t_s, t_m, t_start, t_end, t_name, t_step
		For Each t_m In t_mc
			t_start = getAttr_(t_m.SubMatches(0), "start", "1")
			t_end = getAttr_(t_m.SubMatches(0), "end", "")
			If t_end = "" Then
				Errc.Throw(32)
			End If
			t_step = getAttr_(t_m.SubMatches(0), "step", "1")
			t_name = getAttr_(t_m.SubMatches(0), "name", "i")
			t_s = ""
			t_s = t_s & "<" & Chr(37) & vbcrlf & "For " & t_name & "=" & t_start & " To " & t_end & " Step " & t_step & vbcrlf & Chr(37) & ">"
			t_s = t_s & t_m.SubMatches(1)
			t_s = t_s & "<" & Chr(37) & vbcrlf & "Next" & vbcrlf & Chr(37) & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		If s_regex.Test(p_s) Then
			jxFor_ = jxFor_(p_s)
		Else
			jxFor_ = p_s
		End If
	End Function
	
	'''解析Record标签,用于输出数据集
	'type:1\rs指向记录集,2\sql指向查询语句.默认值为1
	'sqlstr:type为2\sql时，此项为必须值,查询语句变量名
	'zero:新增,开始时计数是否归零,1\true\yes为是,0\false\no为否,默认为1
	'name:记录集名称,最好是指定，默认为rs
	'length：输出记录集的个数,为空为不限制
	'key：循环key变量,默认值为i
	'mod:对key值取模，默认为2(暂时不实现)
	'conn:数据源的连接,默认Db.conn(type为2\sql时应尽量显式指定)
	'close:2\all循环结束关闭记录集析构,1\true\yes循环结束后关闭记录集,0\false\no循环结束后不关闭记录集(代码手动关闭,建议少用),默认为1
	'p_s:要解析的模板代码
	Private Function jxRecord_(Byval p_s)
		s_regex.Pattern = "<record[\s]+([^>]*)[\s]*>[\s]*[\n]?(((?!<record(.|\n))(.|\n)(?!record>))+)<\/record>[\s]*[\n]?"
		Dim t_mc : Set t_mc = s_regex.Execute(p_s)
		Dim t_s, t_m, t_type, t_name, t_length, t_key, t_mod, t_close, t_sqlstr, t_zero
		For Each t_m In t_mc
			t_type = getAttr_(t_m.SubMatches(0), "type", "1")
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", "rs"))
			t_length = toVar_(getAttr_(t_m.SubMatches(0), "length", ""))
			t_key = toVar_(getAttr_(t_m.SubMatches(0), "key", "i"))
			t_mod = toVar_(getAttr_(t_m.SubMatches(0), "mod", "2"))
			t_conn = toVar_(getAttr_(t_m.SubMatches(0), "conn", "Db.Conn"))
			t_close = getAttr_(t_m.SubMatches(0), "close", "1")
			t_zero = getAttr_(t_m.SubMatches(0), "zero", "1")
			t_s = ""
			Select Case LCase(Trim(Cstr(t_type)))
			Case "1","rs"
				t_s = t_s & "<" & Chr(37) & vbcrlf
				'计数初始化
				If Cstr(t_zero) = "1" Or Lcase(t_zero) = "true" Or Lcase(t_zero) = "yes" Then
					t_s = t_s & "Dim "  & t_key & " : " & t_key & " = 0" & vbcrlf
				End If
				t_s = t_s & "Do While Not " & t_name & ".Eof" & vbcrlf
				t_s = t_s & t_key & " = " & t_key & " + 1" & vbcrlf
				t_s = t_s & Chr(37) & ">"
				t_s = t_s & t_m.SubMatches(1)
				t_s = t_s & "<" & Chr(37) & vbcrlf
				If Has(t_length) Then
					t_s = t_s & "If " & t_key & " >= " & t_length & " Then Exit Do" & vbcrlf
				End If
				t_s = t_s & t_name & ".MoveNext" & vbcrlf
				t_s = t_s & "Loop" & vbcrlf
				Select Case LCase(Trim(Cstr(t_close)))
				Case "0","false","no"
					'Do Nothing
				Case "1","true","yes"
					t_s = t_s & t_name & ".Close" & vbcrlf
				Case "2","all"
					t_s = t_s & t_name & ".Close" & vbcrlf
					t_s = t_s & "Set " & t_name & " = Nothing" & vbcrlf
				End Select
				t_s = t_s & Chr(37) & ">"
			Case "2","sql"
				t_sqlstr = toVar_(getAttr_(t_m.SubMatches(0), "sqlstr", ""))
				If t_sqlstr = "" Then
					'Response.Write("Found Err. The SqlStr Must Be Have!")
					'Response.End
					Errc.Throw(33)
				End If
				t_s = t_s & "<" & Chr(37) & vbcrlf
				'析构之前的连接
				t_s = t_s & "If TypeName(" & t_name & ") = " & Chr(34) & "Recordset" & Chr(34) & " Then" & vbcrlf
				t_s = t_s & "If " & t_name & ".State <> 0 Then" & vbcrlf
				t_s = t_s & t_name & ".Close" & vbcrlf
				t_s = t_s & "End If" & vbcrlf
				'如果不是,那就建立
				t_s = t_s & "Else" & vbcrlf
				t_s = t_s & "Set " & t_name & " = Server.Createobject(" & Chr(34) & "Adodb.Recordset" & Chr(34) & ")" & vbcrlf
				t_s = t_s & "End If" & vbcrlf
				'建立连接
				t_s = t_s & t_name & ".Open " & t_sqlstr & ", " & t_conn & vbcrlf
				''''''''重复代码应精简
				'计数初始化
				If Cstr(t_zero) = "1" Or Lcase(t_zero) = "true" Or Lcase(t_zero) = "yes" Then
					t_s = t_s & "Dim "  & t_key & " : " & t_key & " = 0" & vbcrlf
				End If
				t_s = t_s & "Do While Not " & t_name & ".Eof" & vbcrlf
				t_s = t_s & t_key & " = " & t_key & " + 1" & vbcrlf
				t_s = t_s & Chr(37) & ">"
				t_s = t_s & t_m.SubMatches(1)
				t_s = t_s & "<" & Chr(37) & vbcrlf
				If IsNumeric(t_length) Then
					t_s = t_s & "If " & t_key & " >= " & t_length & " Then Exit Do" & vbcrlf
				End If
				t_s = t_s & t_name & ".MoveNext" & vbcrlf
				t_s = t_s & "Loop" & vbcrlf
				Select Case LCase(Trim(Cstr(t_close)))
				Case "0","false","no"
					'Do Nothing
				Case "1","true","yes"
					t_s = t_s & t_name & ".Close" & vbcrlf
				Case "2","all"
					t_s = t_s & t_name & ".Close" & vbcrlf
					t_s = t_s & "Set " & t_name & " = Nothing" & vbcrlf
				End Select
				t_s = t_s & Chr(37) & ">"
			Case Else
				'出错处理
				Errc.Throw(34)
			End Select
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		If s_regex.Test(p_s) Then
			jxRecord_ = jxRecord_(p_s)
		Else
			jxRecord_ = p_s
		End If
	End Function
	
	'''解析Switch标签,包括开始标签、结束标签、case标签、caseelse/default标签
	'select标签无嵌套问题
	'value有双引号转换问题(字符串包含双引号使用Chr(34)来解决,逗号Chr(44)), 添加辨别标签避免双引号转换问题
	'属性type用于标识value值类型(数字、字符串、变量)
	'type可能值:1、str(字符串)/2、num(数字)/3、var(变量)/多值1,2,3
	'未指定type时,对value进行判断(多值匹配时type应尽量显式提供)
	'p_s:要解析的模板代码
	Private Function jxSwitch_(Byval p_s)
		Dim t_name, t_value, t_type, t_va, t_vs, t_ta
		Dim t_mc, t_m, t_n, t_v, t_s, t_i
		'<switch name="var">
		s_regex.Pattern = "<switch[\s]+([^>]*)[\s]*>[\s]*[\n]?"
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			If t_name = "" Then
				Errc.Throw(45)
			End If
			t_s = "<" & Chr(37) & "Select Case " & t_name & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'<case value="1,2,3" type="1" />
		s_regex.Pattern = "<case[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_value = getAttr_(t_m.SubMatches(0), "value", "")
			'多值判断
			t_va = Split(t_value, ",")
			t_type = getAttr_(t_m.SubMatches(0), "type", "")
			t_ta = Split(t_type, ",")
			If UBound(t_ta) > 0 Then
				t_type = "arr"
				'多值格式个数不同引发错误
				If UBound(t_va) <> UBound(t_ta) Then
					Errc.Throw(46)
				End If
			End If
			If t_value = "" Then
				t_s = "<" & Chr(37) & "Case """"" & Chr(37) & ">"
			Else
				t_s = ""
				'类型初始化
				t_n = False
				t_v = False
				'确认值类型
				If t_type = "" Then
					For Each t_vs In t_va
						If IsNumeric(t_vs) Then
							t_n = True
						End If
						If Left(t_vs, 1) = "$" Then
							t_v = True
						End If
					Next
					If t_n Then
						t_type = "num"
					ElseIf t_v Then
						t_type = "var"
					Else
						'默认为字符串
						t_type = "str"
					End If
				End If
				Select Case Lcase(t_type)
				Case "arr"
					'数组每个对应上
					For t_i = 0 To UBound(t_va)
						Select Case Lcase(Cstr(t_ta(t_i)))
						Case "1","str"
							t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
						Case "2","num"
							t_s = t_s & t_va(t_i)
						Case "3","var"
							t_s = t_s & toVar_(t_va(t_i))
						Case Else
							t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
						End Select
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					Next
				Case "1","str"
					For t_i = 0 To UBound(t_va)
						t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					Next
				Case "2","num"
					For t_i = 0 To UBound(t_va)
						t_s = t_s & t_va(t_i)
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					Next
				Case "3","var"
					For t_i = 0 To UBound(t_va)
						t_s = t_s & toVar_(t_va(t_i))
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					Next
				Case Else
					For t_i = 0 To UBound(t_va)
						t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					Next
				End Select
				t_s = "<" & Chr(37) & "Case " & t_s & Chr(37) & ">"
			End If
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'<caseelse/>
		s_regex.Pattern = "<caseelse[\s]*[\/]?[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "Case Else" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		'<default/>
		s_regex.Pattern = "<default[\s]*[\/]?[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "Case Else" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		'</switch>
		s_regex.Pattern = "<[\s]*[\/]{1}switch[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End Select" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		Set t_mc = Nothing
		jxSwitch_ = p_s
	End Function
	
	'''解析Compare标签
	'属性name:要比较的变量名
	'属性value:要比较的值,支持变量
	'属性type:比较值的类型,为空时进行自动判断
	'属性math:运算(eq/equal/neq/notequal/gt/egt/lt/elt/heq/nheq)
	'p_s:要解析的模板代码
	Private Function jxCompare_(Byval p_s)
		Dim t_mc, t_m, t_name, t_value, t_type, t_math, t_s, t_symb
		'解析别名标签
		Dim t_bq, t_bqa : t_bqa = Split("eq,equal,neq,notequal,gt,egt,lt,elt,heq,nheq", ",")
		For Each t_bq In t_bqa
			s_regex.Pattern = "<" & t_bq & "[\s]+([^>]*)[\s]*[\/]?[\s]*>"
			t_s = "<compare $1 math=" & Chr(34) & t_bq & Chr(34) & ">"
			p_s = s_regex.Replace(p_s,t_s)
			s_regex.Pattern = "<[\s]*[\/]{1}" & t_bq & "[\s]*>"
			t_s = "</compare>"
			p_s = s_regex.Replace(p_s,t_s)
		Next
		s_regex.Pattern = "<compare[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			t_value = getAttr_(t_m.SubMatches(0), "value", "")
			t_type = getAttr_(t_m.SubMatches(0), "type", "")
			t_math = getAttr_(t_m.SubMatches(0), "math", "eq")
			If t_name = "" Then
				Errc.Throw(47)
			End If
			If t_type = "" Then
				If IsNumeric(t_value) Then
					t_type = "num"
				ElseIf Left(t_value, 1) = "$" Then
					t_type = "var"
				Else
					t_type = "str"
				End If
			End If
			Select Case Lcase(Cstr(t_type))
			Case "1","str"
				t_value = Chr(34) & t_value & Chr(34)
			Case "2","num"
				'Do Nothing
			Case "3","var"
				t_value = toVar_(t_value)
			Case Else
				t_value = Chr(34) & t_value & Chr(34)
			End Select
			t_s = ""
			Select Case Lcase(t_math)
			Case "heq"
				t_s = "<" & Chr(37) & "If " & t_name & " = " & t_value & " And VarType(" & t_name & ") = VarType(" & t_value & ") Then" & Chr(37)  & ">"
			Case "nheq"
				t_s = "<" & Chr(37) & "If " & t_name & " <> " & t_value & " Or VarType(" & t_name & ") <> VarType(" & t_value & ") Then" & Chr(37)  & ">"
			Case "eq","equal"
				t_symb = " = "
			Case "neq","notequal"
				t_symb = " <> "
			Case "gt"
				t_symb = " > "
			Case "egt"
				t_symb = " >= "
			Case "lt"
				t_symb = " < "
			Case "elt"
				t_symb = " <= "
			Case Else
				t_symb = " = "
			End Select
			If t_s = "" Then
				t_s = "<" & Chr(37) & "If " & t_name & t_symb & t_value & " Then" & Chr(37)  & ">"
			End If
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'</compare>
		s_regex.Pattern = "<[\s]*[\/]{1}compare[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End If" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		Set t_mc = Nothing
		jxCompare_ = p_s
	End Function
	
	'''解析Range标签
	'属性name:要比较的变量名
	'属性value:要比较的值,支持变量
	'属性type:比较值的类型,为空时进行自动判断
	'属性math:运算(in/notin/nin/between/btw/notbetween/nbtw)
	'属性border:是否包含边界值,between类型可用,默认为True
	'对于in类型(包括in/notin/nin)支持arr的type属性,但是在多值时不建议使用,
	'如<in name="$nme" value="$arr,1,2,3" type="arr,num,num,num">可以正常解析,原理是将1,2,3加入到arr数组进行合并,然后进行in判断
	'p_s:要解析的模板代码
	Private Function jxRange_(Byval p_s)
		Dim t_bq, t_bqa : t_bqa = Split("in,notin,nin,between,btw,notbetween,nbtw", ",")
		Dim t_name, t_math, t_value, t_type, t_border, t_s, t_va, t_ta, t_a, t_aa, t_na
		Dim t_mc, t_m, t_i, t_bt1, t_bt2
		'解析别名标签
		For Each t_bq In t_bqa
			s_regex.Pattern = "<" & t_bq & "[\s]+([^>]*)[\s]*[\/]?[\s]*>"
			t_s = "<range $1 math=" & Chr(34) & t_bq & Chr(34) & ">"
			p_s = s_regex.Replace(p_s,t_s)
			s_regex.Pattern = "<[\s]*[\/]{1}" & t_bq & "[\s]*>"
			t_s = "</range>"
			p_s = s_regex.Replace(p_s,t_s)
		Next
		s_regex.Pattern = "<range[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			t_math = Lcase(Trim(getAttr_(t_m.SubMatches(0), "math", "in")))
			t_value = getAttr_(t_m.SubMatches(0), "value", "")
			t_border = Lcase(Trim(getAttr_(t_m.SubMatches(0), "border", "True")))
			t_type = Lcase(Trim(Cstr(getAttr_(t_m.SubMatches(0), "type", ""))))
			'多值判断
			t_va = Split(t_value, ",")
			t_ta = Split(t_type, ",")
			If UBound(t_ta) > 0 Then
				t_type = "comp"
				'多值格式个数不同引发错误
				If UBound(t_va) <> UBound(t_ta) Then
					Errc.Throw(50)
				End If
			End If
			'确认各值类型,构建in类型的Array
			t_s = ""
			'最后组装的arr实体
			t_a = ""
			'最后附件的arr数组字符实体
			t_aa = ""
			Select Case t_type
			Case ""
				'为空时对每个值进行检测
				For t_i = 0 To UBound(t_va)
					t_na = True
					If IsNumeric(t_va(t_i)) Then
						t_s = t_s & t_va(t_i)
					ElseIf Left(t_va(t_i), 1) = "$" Then
						'如果是数组应进行额外处理
						If Eval("VarType(" & toVar_(t_va(t_i)) & ")") >= 8192 Then
							If UBound(t_va) = 0 Then
								'单个数组变量直接返回
								t_a = toVar_(t_va(t_i))
								Exit For
							Else
								t_na = False
								t_aa = t_aa & " Or IsIn(" & t_name & "," & toVar_(t_va(t_i)) & ")"
							End If
						Else
							t_s = t_s & toVar_(t_va(t_i))
						End If
					Else
						t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
					End If
					If t_na Then
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					End If
				Next
			Case "1","str"
				For t_i = 0 To UBound(t_va)
					t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
					If t_i <> UBound(t_va) Then
						t_s = t_s & ","
					End If
				Next
			Case "2","num"
				For t_i = 0 To UBound(t_va)
					t_s = t_s & t_va(t_i)
					If t_i <> UBound(t_va) Then
						t_s = t_s & ","
					End If
				Next
			Case "3","var"
				For t_i = 0 To UBound(t_va)
					t_s = t_s & toVar_(t_va(t_i))
					If t_i <> UBound(t_va) Then
						t_s = t_s & ","
					End If
				Next
			Case "4","arr"
				If UBound(t_va) = 0 Then
					t_a = toVar_(t_value)
				Else
					For t_i = 0 To UBound(t_va)
						t_aa = t_aa & " Or IsIn(" & t_name & "," & toVar_(t_va(t_i)) & ")"
					Next
				End If
			Case "comp"
				'复杂类型
				For t_i = 0 To UBound(t_va)
					t_na = True
					Select Case Lcase(Trim(Cstr(t_ta(t_i))))
					Case "1","str"
						t_s = t_s & Chr(34) & t_va(t_i) & Chr(34)
					Case "2","num"
						t_s = t_s & t_va(t_i)
					Case "3","var"
						t_s = t_s & toVar_(t_va(t_i))
					Case "4", "arr"
						t_na = False
						t_aa = t_aa & " Or IsIn(" & t_name & "," & toVar_(t_va(t_i)) & ")"
					Case Else
						Errc.Throw(51)
					End Select
					If t_na Then
						If t_i <> UBound(t_va) Then
							t_s = t_s & ","
						End If
					End If
				Next
			Case Else
				Errc.Throw(51)
			End Select
			'决定最后Arr
			If t_a = "" Then
				If Right(t_s, 1) = "," Then
					t_s = Left(t_s, Len(t_s)-1)
				End If
				t_a = "Array(" & t_s & ")"
			End If
			'确定between类型的两个值
			If IsIn(t_math, Split("3,between,btw,4,notbetween,nbtw", ",")) Then
				If UBound(t_va)<>1 Then
					Errc.Throw(53)
				End If
				'between类型不能有arr存在
				If InStr(t_type, "arr") > 0 Then
					Errc.Throw(54)
				End If
				t_bt1 = Max(Split(t_s, ",")(0), Split(t_s, ",")(1))
				t_bt2 = Min(Split(t_s, ",")(0), Split(t_s, ",")(1))
			End If
			Select Case t_math
			Case "1","in"
				If t_aa = "" Then
					t_s = "<" & Chr(37) & "If IsIn(" & t_name & ", " & t_a & ") Then" & Chr(37)  & ">"
				Else
					t_s = "<" & Chr(37) & "If (IsIn(" & t_name & ", " & t_a & ")" & t_aa & ") Then" & Chr(37)  & ">"
				End If
			Case "2","notin","nin"
				If t_aa = "" Then
					t_s = "<" & Chr(37) & "If Not IsIn(" & t_name & ", " & t_a & ") Then" & Chr(37)  & ">"
				Else
					t_s = "<" & Chr(37) & "If Not (IsIn(" & t_name & ", " & t_a & ")" & t_aa & ") Then" & Chr(37)  & ">"
				End If
			Case "3","between","btw"
				If t_border = "1" Or t_border = "true" Or t_border="yes" Then
					'带边界值
					t_s = "<" & Chr(37) & "If " & t_name & " >= " & t_bt2 & " And " & t_name & "<= " & t_bt1 & " Then" & Chr(37)  & ">"
				Else
					'不带边界值
					t_s = "<" & Chr(37) & "If " & t_name & " > " & t_bt2 & " And " & t_name & "< " & t_bt1 & " Then" & Chr(37)  & ">"
				End If
			Case "4","notbetween","nbtw"
				If t_border = "1" Or t_border = "true" Or t_border="yes" Then
					'带边界值
					t_s = "<" & Chr(37) & "If Not (" & t_name & " >= " & t_bt2 & " And " & t_name & "<= " & t_bt1 & ") Then" & Chr(37)  & ">"
				Else
					'不带边界值
					t_s = "<" & Chr(37) & "If Not (" & t_name & " > " & t_bt2 & " And " & t_name & "< " & t_bt1 & ") Then" & Chr(37)  & ">"
				End If
			Case Else
				Errc.Throw(52)
			End Select
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'</range>
		s_regex.Pattern = "<[\s]*[\/]{1}range[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End If" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		Set t_mc = Nothing
		jxRange_ = p_s
	End Function
	
	'''解析Empty标签,包括(Empty/Notempty/Nempty)
	'属性name,要判断的值
	'p_s:要解析的模板代码
	Private Function jxEmpty_(Byval p_s)
		Dim t_m, t_mc, t_name, t_s
		'Empty标签
		s_regex.Pattern = "<empty[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			If t_name = "" Then
				Errc.Throw(55)
			End If
			t_s = "<" & Chr(37) & "If IsN(" & t_name & ") Then" & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'Notempty/Nempty标签
		s_regex.Pattern = "<n(ot)?empty[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(1), "name", ""))
			If t_name = "" Then
				Sa.Errc.Throw(56)
			End If
			t_s = "<" & Chr(37) & "If Has(" & t_name & ") Then" & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		'</empty>
		s_regex.Pattern = "<[\s]*[\/]{1}empty[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End If" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		'</notempty></nempty>
		s_regex.Pattern = "<[\s]*[\/]{1}n(ot)?empty[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End If" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		jxEmpty_ = p_s
	End Function
	
	'''解析Const标签
	'属性name,要定义的常量名
	'属性value,常量值
	'属性type,常量类型,仅支持num、str类型
	'需要进行复杂常量定义,请使用asp标签
	'p_s:要解析的模板代码
	Private Function jxConst_(Byval p_s)
		Dim t_m, t_mc, t_name, t_value, t_type, t_s
		s_regex.Pattern = "<const[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			t_value = getAttr_(t_m.SubMatches(0), "value", "")
			t_type = Lcase(Trim(Cstr(getAttr_(t_m.SubMatches(0), "value", ""))))
			If t_name = "" Then
				Errc.Throw(57)
			End If
			Select Case t_type
			Case ""
				If Not IsNumeric(t_value) Then
					t_value = Chr(34) & t_value & Chr(34)
				End If
			Case "1","str"
				t_value = Chr(34) & t_value & Chr(34)
			Case "2","num"
				'DoNothing
			Case Else
				Errc.Throw(58)
			End Select
			t_s = "<" & Chr(37) & "Const " & t_name & " = " & t_value & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		jxConst_ = p_s
	End Function
	
	'''解析Dim标签
	'属性name,要定义的变量名
	'属性value,变量值
	'属性type,常量类型,仅支持num、str、var类型
	'需要进行复杂变量定义,请使用asp标签
	'p_s:要解析的模板代码
	Private Function jxDim_(Byval p_s)
		Dim t_m, t_mc, t_name, t_value, t_type, t_s
		s_regex.Pattern = "<dim[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_name = toVar_(getAttr_(t_m.SubMatches(0), "name", ""))
			t_value = getAttr_(t_m.SubMatches(0), "value", "")
			t_type = Lcase(Trim(Cstr(getAttr_(t_m.SubMatches(0), "value", ""))))
			If t_name = "" Then
				Errc.Throw(59)
			End If
			Select Case t_type
			Case ""
				If Not IsNumeric(t_value) Then
					t_value = Chr(34) & t_value & Chr(34)
				End If
			Case "1","str"
				t_value = Chr(34) & t_value & Chr(34)
			Case "2","num"
				'DoNothing
			Case "3","var"
				t_value = toVar_(t_value)
			Case Else
				Errc.Throw(60)
			End Select
			t_s = "<" & Chr(37) & "Dim " & t_name & " : " & t_name & " = " & t_value & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		jxDim_ = p_s
	End Function
	
	'''解析If标签,包括(If,ElseIf)
	'属性condition,返回类型为bool的变量或常量或函数,含运算符建议使用Compare标签
	'If标签主要用于单变量True判断
	'p_s:要解析的模板代码
	Private Function jxIf_(Byval p_s)
		Dim t_m, t_mc, t_condition, t_s
		'If标签
		s_regex.Pattern = "<if[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_condition = toVar_(getAttr_(t_m.SubMatches(0), "condition", ""))
			If t_condition = "" Then
				Errc.Throw(48)
			End If
			t_s = "<" & Chr(37) & "If " & t_condition & " Then" & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		'ElseIf标签
		s_regex.Pattern = "<elseif[\s]+([^>]*)[\s]*[\/]?[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_condition = toVar_(getAttr_(t_m.SubMatches(0), "condition", ""))
			If t_condition = "" Then
				Errc.Throw(49)
			End If
			t_s = "<" & Chr(37) & "ElseIf " & t_condition & " Then" & Chr(37)  & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		'</if>
		s_regex.Pattern = "<[\s]*[\/]{1}if[\s]*>[\s]*[\n]?"
		t_s = "<" & Chr(37) & "End If" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		jxIf_ = p_s
	End Function
	
	'''解析Redirect标签
	'属性url,跳转的目标,支持变量
	'属性condition,跳转的条件,仅支持返回bool类型的变量/常量/函数/运算。如果condition为空则直接进行跳转
	'对于复杂条件跳转,请使用asp标签
	'p_s:要解析的模板代码
	Private Function jxRedirect_(Byval p_s)
		Dim t_m, t_mc, t_url, t_condition, t_s
		s_regex.Pattern = "<redirect[\s]+([^>]*)[\s]*>[\s]*[\n]?"		
		Set t_mc = s_regex.Execute(p_s)
		For Each t_m In t_mc
			t_url = getAttr_(t_m.SubMatches(0), "url", "")
			If Left(t_url,1) = "$" Then
				t_url = toVar_(t_url)
			Else
				t_url = Chr(34) & t_url & Chr(34)
			End If
			t_condition = toVar_(getAttr_(t_m.SubMatches(0), "condition", ""))
			If t_url = "" Then
				Errc.Throw(61)
			End If
			If t_condition = "" Then
				t_s = "<" & Chr(37) & "Response.Redirect(" & t_url & ")" & Chr(37)  & ">"
			Else
				t_s = "<" & Chr(37) & "If " & t_condition & " Then Response.Redirect(" & t_url & ") End If" & Chr(37)  & ">"
			End If
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = Nothing
		jxRedirect_ = p_s
	End Function
	
	'''解析Else标签
	'Else属于公用标签,需要进行统一解析处理
	'p_s:要解析的模板代码
	Private Function jxElse_(Byval p_s)
		s_regex.Pattern = "<[\s]*else[\s]*[\/]{1}[\s]*>[\s]*[\n]?"
		Dim t_s : t_s = "<" & Chr(37) & "Else" & Chr(37) & ">"
		p_s = s_regex.Replace(p_s,t_s)
		jxElse_ = p_s
	End Function
	
	'''解析Asp标签,用于输出asp语句
	'p_s:要解析的模板代码
	Private Function jxAsp_(Byval p_s)
		s_regex.Pattern = "<asp[\s]*>(((?!<asp(.|\n))(.|\n)(?!asp>))+)<\/asp>"
		t_s = "<" & Chr(37) & vbcrlf & "$1" & vbcrlf & Chr(37)  & ">"
		jxAsp_ = s_regex.Replace(p_s,t_s)
	End Function
	
	'''解析简单赋值标签
	'p_s:要解析的模板代码
	Private Function jxStr_(Byval p_s)
		s_regex.Pattern = "\{\$([^\}]*)\}"
		Dim t_mc : Set t_mc = s_regex.Execute(p_s)
		Dim t_s, t_m
		For Each t_m In t_mc
			t_s = t_m.SubMatches(0)
			'还原双引号和单引号
			t_s = Replace(t_s, s_dqmarkstr, """")
			t_s = Replace(t_s, s_sqmarkstr, "'")
			t_s = "<" & Chr(37) & "Response.Write(" & t_s & ")" & Chr(37) & ">"
			p_s = Replace(p_s, t_m.Value, t_s)
		Next
		Set t_mc = NoThing
		jxStr_ = p_s
	End Function
	
	'''解析模板,返回处理结果
	'p_s:要解析的模板代码
	Private Function jx_(Byval p_s)
		Dim t_s : t_s = p_s
		'最先应该收集Literal标签
		t_s = sjLiteral_(t_s)
		'include标签优先解析
		t_s = jxInclude_(t_s)
		t_s = jxSwitch_(t_s)
		t_s = jxCompare_(t_s)
		t_s = jxRange_(t_s)
		t_s = jxEmpty_(t_s)
		t_s = jxIf_(t_s)
		t_s = jxElse_(t_s)
		t_s = jxFor_(t_s)
		t_s = jxForEach_(t_s)
		t_s = jxRecord_(t_s)
		t_s = jxConst_(t_s)
		t_s = jxDim_(t_s)
		t_s = jxRedirect_(t_s)
		t_s = jxAsp_(t_s)
		t_s = jxStr_(t_s)
		'还原Literal标签必须放在最后
		t_s = hfLiteral_(t_s)
		jx_ = t_s
	End Function
	
	'''通过ini语言文件返回语言包代码
	'p_f:语言包ini文件路径
	Private Function lang_(Byval p_f)
		Dim t_fc : t_fc = readFile_(p_f)
		Dim t_fl : t_fl = Split(t_fc, vbcrlf)
		Dim t_c : t_c = ""
		Dim t_a, t_x
		For Each t_x In t_fl
			'含双引号情况
			If InStr(t_x, Chr(34)) > 0 Then
				t_a = Split(t_x, "=")
				If UBound(t_a) = 1 Then
					t_c = t_c & "L_" & t_a(0) & " = " & t_a(1) & vbcrlf
				End If
			Else
				'普通情况
				t_a = Split(t_x, "=")
				If UBound(t_a) = 1 Then
					t_c = t_c & "L_" & t_a(0) & " = " & Chr(34) & t_a(1) & Chr(34) & vbcrlf
				End If
			End If
		Next
		t_c = "<" & Chr(37) & vbcrlf & t_c & Chr(37) & ">"
		lang_ = t_c
	End Function
	
	'''编译生成需要的语言文件,返回插入的代码段
	'''该函数仅在生成时有效,且使用了ashapo核心fso
	'''注意该函数生成的文件使用了核心函数ReqGet
	'伪装的公用函数
	'p_s:按运行模式指定语言包编译模式(附加run模式,只返回代码段,不进行文件生成,outer模式,返回入口文件代码)
	Public Function ByLang__(Byval p_s)
		If p_s = "" Then
			p_s = Lcase(C_AppStatus)
		End If
		p_s = Lcase(p_s)
		'系统是否需要编译单文件语言包
		Dim t_mf : t_mf = IsIn(p_s, Array("default", "record"))
		Dim t_dl : t_dl = Lang()
		Dim t_lp : t_lp = "/" & C_AppFolder & "/" & C_LangFolder & "/"
		Dim t_lcp : t_lcp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_lang/"
		Dim t_g : t_g = s_nowG
		Dim t_m : t_m = s_nowM
		Dim t_a : t_a = s_nowA
		'default(常规)\record(日志)模式:正常生成
		Dim t_os1 : t_os1 = "<" & Chr(37) & "Select Case Lang()" & Chr(37) & ">" & vbcrlf
		'debug(调试)模式/speed(性能)模式:不生成(t_os2当返回值)
		Dim t_os2 : t_os2 = "<" & Chr(37) & "Select Case Lang()" & Chr(37) & ">" & vbcrlf
		'修正系统没有的group,防止建立不应有的语言包入口文件
		If isFile_("/" & C_AppFolder & "/" & C_ActionFolder & "/" & t_g & "/" & t_m & C_ActionSuf & ".asp") Then
			If Not hasFunSub_(t_a, readFile_("/" & C_AppFolder & "/" & C_ActionFolder & "/" & t_g & "/" & t_m & C_ActionSuf & ".asp")) Then
				t_g = "ashapo"
			End If
		Else
			t_g = "ashapo"
		End If
		If p_s = "run" Or p_s = "outer" Then
			t_g = "ashapo"
		End If
		Dim t_i, t_fol : t_fol = dirList_(t_lp, 2)
		For t_i = 0 To UBound(t_fol,2)
			t_os1 = t_os1 & "<" & Chr(37) & "Case " & Chr(34) & Lcase(t_fol(0,t_i)) & Chr(34) & Chr(37) & ">" & vbcrlf
			t_os2 = t_os2 & "<" & Chr(37) & "Case " & Chr(34) & Lcase(t_fol(0,t_i)) & Chr(34) & Chr(37) & ">" & vbcrlf
			'开始编译生成_lang缓存文件
			'当前系统语言包,调试/性能模式下不生成
			If isFile_("/" & C_CoreFolder & "/Lang/" & t_fol(0,t_i) & ".ini") Then
				If (Not isFile_(t_lcp & "ashapo_" & t_fol(0,t_i) & ".asp")) And t_mf Then
					If Not createFile_(t_lcp & "ashapo_" & t_fol(0,t_i) & ".asp", lang_("/" & C_CoreFolder & "/Lang/" & t_fol(0,t_i) & ".ini"),0) Then
						Errc.Throw(38)
					End If
				End If
				t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & "ashapo_" & t_fol(0,t_i) & ".asp" & Chr(34) & "-->" & vbcrlf
				t_os2 = t_os2 & lang_("/" & C_CoreFolder & "/Lang/" & t_fol(0,t_i) & ".ini") & vbcrlf
			End If
			'common.ini公用语言包
			If isFile_(t_lp & t_fol(0,t_i) & "/common.ini") Then
				If (Not isFile_(t_lcp & t_fol(0,t_i) & C_CacheFit & "common.asp")) And t_mf Then
					If Not createFile_(t_lcp & t_fol(0,t_i) & C_CacheFit & "common.asp", lang_(t_lp & t_fol(0,t_i) & "/common.ini"),0) Then
						Errc.Throw(36)
					End If
				End If
				t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & t_fol(0,t_i) & C_CacheFit & "common.asp" & Chr(34) & "-->" & vbcrlf
				t_os2 = t_os2 & lang_(t_lp & t_fol(0,t_i) & "/common.ini") & vbcrlf
			End If
			'当前分组语言包,如index.ini
			If isFile_(t_lp & t_fol(0,t_i) & "/" & t_g & ".ini") Then
				If (Not isFile_(t_lcp & t_fol(0,t_i) & C_CacheFit & t_g & ".asp")) And t_mf Then
					If Not createFile_(t_lcp & t_fol(0,t_i) & C_CacheFit & t_g & ".asp", lang_(t_lp & t_fol(0,t_i) & "/" & t_g & ".ini"),0) Then
						Errc.Throw(37)
					End If
				End If
				t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & t_fol(0,t_i) & C_CacheFit & t_g & ".asp" & Chr(34) & "-->" & vbcrlf
				t_os2 = t_os2 & lang_(t_lp & t_fol(0,t_i) & "/" & t_g & ".ini") & vbcrlf
			End If
		Next
		'加载当前默认语言
		t_os1 = t_os1 & "<" & Chr(37) & "Case Else" & Chr(37) & ">" & vbcrlf
		t_os2 = t_os2 & "<" & Chr(37) & "Case Else" & Chr(37) & ">" & vbcrlf
		'当前系统语言包
		If isFile_("/" & C_CoreFolder & "/Lang/" & t_dl & ".ini") Then
			If (Not isFile_(t_lcp & "ashapo_" & t_dl & ".asp")) And t_mf Then
				If Not createFile_(t_lcp & "ashapo_" & t_dl & ".asp", lang_("/" & C_CoreFolder & "/Lang/" & t_dl & ".ini"),0) Then
					Errc.Throw(38)
				End If
			End If
			t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & "ashapo_" & t_dl & ".asp" & Chr(34) & "-->" & vbcrlf
			t_os2 = t_os2 & lang_("/" & C_CoreFolder & "/Lang/" & t_dl & ".ini") & vbcrlf
		End If
		'common.ini公用语言包
		If isFile_(t_lp & t_dl & "/common.ini") Then
			If (Not isFile_(t_lcp & t_dl & C_CacheFit & "common.asp")) And t_mf Then
				If Not createFile_(t_lcp & t_dl & C_CacheFit & "common.asp", lang_(t_lp & t_dl & "/common.ini"),0) Then
					Errc.Throw(36)
				End If
			End If
			t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & t_dl & C_CacheFit & "common.asp" & Chr(34) & "-->" & vbcrlf
			t_os2 = t_os2 & lang_(t_lp & t_dl & "/common.ini") & vbcrlf
		End If
		'当前分组语言包,如index.ini
		If isFile_(t_lp & t_dl & "/" & t_g & ".ini") Then
			If (Not isFile_(t_lcp & t_dl & C_CacheFit & t_g & ".asp")) And t_mf Then
				If Not createFile_(t_lcp & t_dl & C_CacheFit & t_g & ".asp", lang_(t_lp & t_dl & "/" & t_g & ".ini"),0) Then
					Errc.Throw(37)
				End If
			End If
			t_os1 = t_os1 & "<!--#include virtual=" & Chr(34) & t_lcp & t_dl & C_CacheFit & t_g & ".asp" & Chr(34) & "-->" & vbcrlf
			t_os2 = t_os2 & lang_(t_lp & t_dl & "/" & t_g & ".ini") & vbcrlf
		End If
		t_os1 = t_os1 & "<" & Chr(37) & vbcrlf
		t_os2 = t_os2 & "<" & Chr(37) & vbcrlf
		'结束
		t_os1 = t_os1 & "End Select" & vbcrlf
		t_os2 = t_os2 & "End Select" & vbcrlf
		t_os1 = t_os1 & Chr(37) & ">"
		t_os2 = t_os2 & Chr(37) & ">"
		Select Case p_s
		Case "run"
			If IsIn(Lcase(C_AppStatus), Array("default", "record")) Then
				ByLang__ = "<!--#include virtual=" & Chr(34) & t_lcp & t_g & ".asp" & Chr(34) & "-->"
			ElseIf IsIn(Lcase(C_AppStatus), Array("debug","speed")) Then
				ByLang__ = t_os2
			Else
				'其他模式出错,置空
				ByLang__ = ""
			End If
		Case "outer"
			If IsIn(Lcase(C_AppStatus), Array("default", "record")) Then
				ByLang__ = t_os1
			ElseIf IsIn(Lcase(C_AppStatus), Array("debug","speed")) Then
				ByLang__ = t_os2
			Else
				'其他模式出错,置空
				ByLang__ = ""
			End If
		Case "debug","speed"
			ByLang__ = t_os2
		Case "default","record"
			'将代码段写入文件
			If Not isFile_(t_lcp & t_g & ".asp") Then
				If Not createFile_(t_lcp & t_g & ".asp", t_os1,0) Then
					Errc.Throw(35)
				End If
			End If
			ByLang__ = "<!--#include virtual=" & Chr(34) & t_lcp & t_g & ".asp" & Chr(34) & "-->"
		End Select
	End Function
	
	'''变量预定义
	'''这是改进版的变量赋值Sign,放弃使用ExecuteGlobal，改用定义全局变量
	'''支持数组定义
	'''例参数"arr|5"表示定义名为arr的一维数组,其数组大小为6(最大可用下标5)
	'''例参数"arr|5|4"表示定义名为arr的二维数组,其数组大小为6X5
	'p_p:变量名
	Public Sub [Dim](Byval p_p)
		If InStr(p_p, "|")>0 Then
			Dim t_s, t_a, t_p
			t_a = Split(p_p, "|")
			t_s = t_a(0) & "(" & t_a(1)
			For i=2 To UBound(t_a)
				If IsNumeric(t_a(i)) Then
					t_s = t_s & "," & t_a(i)
				Else
					'本处错误代码未更新
					Errc.Throw(3512)
				End If
			Next
			t_s = t_s & ")"
			t_p = t_s
			t_s = "Dim " & t_s
			's_vcodepre = s_vcodepre & t_s & vbcrlf
			'20131211为缓存格式,将变量定义解析到同一行
			If s_vcodepre = "" Then
				s_vcodepre =  t_s
			Else
				s_vcodepre = s_vcodepre & ", " & t_p
			End If
			ExecuteGlobal(t_s)
		Else
			's_vcodepre = s_vcodepre & "Dim " & p_p & vbcrlf
			'20131211为缓存格式,将变量定义解析到同一行
			If s_vcodepre = "" Then
				s_vcodepre =  "Dim " & p_p
			Else
				s_vcodepre = s_vcodepre & ", " & p_p
			End If
			ExecuteGlobal("Dim " & p_p)
		End If
	End Sub
	
	'''变量预定义
	'Assign和Dim的区别是Assign不会被格式化而每次都以ExecuteGlobal形式进行
	'Assign主要使用在跳转页面
	'使用效率上Dim>Assign,故能用Dim的地方请不要使用Assign
	'p_p:变量名
	Public Sub Assign(Byval p_p)
		If InStr(p_p, "|")>0 Then
			Dim t_str, t_arr
			t_arr = Split(p_p, "|")
			t_str = t_arr(0) & "(" & t_arr(1)
			For i=2 To UBound(t_arr)
				If IsNumeric(t_arr(i)) Then
					t_str = t_str & "," & t_arr(i)
				Else
					'本处错误代码未更新
					Errc.Throw(3512)
				End If
			Next
			t_str = t_str & ")"
			t_str = "Dim " & t_str
			ExecuteGlobal(t_str)
		Else
			ExecuteGlobal("Dim " & p_p)
		End If
	End Sub
	
	'''对象预定义
	'对象有析构动作,如果采用变量预定义则析构工作无法执行
	'p_p:对象名
	Public Sub DimObject(Byval p_p)
		[Dim](p_p)
		s_inccodefix = "Set " & p_p & " = Nothing" & vbcrlf & s_inccodefix
	End Sub
	
	'''清空预定义变量
	'未启用
	Public Sub ClearDim()
		s_vcodepre = ""
	End Sub
	
	'''格式化Action代码
	'''修改c代码,除去相关的Tpl、asp等一次性使用函数
	'对:不换行的处理
	'p_s:要格式化的代码(Action类)
	Private Function formatAction_(Byval p_s)
		'删除Include调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Include[\(]?""([^""]*)""[\)]?[ |	]*[:]?"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Include[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Use调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Use[\(]?""([^""]*)""[\)]?[ |	]*[:]?"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Use[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Ext调用,已废弃
		's_regex.Pattern = "[Call]?[\s]*Sa.Ext[\(]?""([^""]*)""[\)]?[ |	]*[:]?"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Ext[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Ecore调用,已废弃
		's_regex.Pattern = "[Call]?[\s]*Sa.Ecore[\(]?""([^""]*)""[\)]?[ |	]*[:]?"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Ecore[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Extends调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Extends[\(]?""([^""]*)""[\)]?[ |	]*[:]?"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Extends[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Dim调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Dim[\(|\s]{1}([^\)\n\r]*)[\)]?[^\r\n]*"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Dim[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除DimObject调用
		's_regex.Pattern = "[Call]?[\s]*Sa.DimObject[\(|\s]{1}([^\)\n\r]*)[\)]?[^\r\n]*"
		s_regex.Pattern = "(Call[ |	]*)?Sa.DimObject[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Display调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Display[\(|\s]{1}([^\)\n\r]*)[\)]?[^\r\n]*"
		s_regex.Pattern = "(Call[ |	]*)?Sa.Display[\(]?""([^""]*)""[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除Show调用
		's_regex.Pattern = "[Call]?[\s]*Sa.Show[\(|\s]{1}([^\)\n\r]*)[\)]?[^\r\n]*"
		s_regex.Pattern = "(Call[ |	]*)?Sa.show[\(]?[\)]?[ |	]*[\:]?[ |	]*"
		p_s = s_regex.Replace(p_s,"")
		'删除注释
		s_regex.Pattern = "[\r\n]{1}[\s|	]*[']+[^\r\n]*"
		p_s = s_regex.Replace(p_s,"")
		'删除多余空行
		s_regex.Pattern = "\n[\s|	]*\r"
		p_s = s_regex.Replace(p_s,"")
		formatAction_ = p_s
	End Function
	
	
	
''''''''''''''''''''''''''''''''''''''''---------------''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''文件编译相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	
	'''往s_codefix添加代码段
	'p_s:要添加的析构代码段
	Private Sub addCodeFix_(Byval p_s)
		If s_codefix = "" Then
			s_codefix = p_s
		Else
			s_codefix = p_s & " : " & s_codefix
		End If
	End Sub
	
	'''由文件路径获取完整的include代码(包括内部再include)
	'p_p:文件路径
	Private Function incReadByFile_(Byval p_p)
		Dim t_c, t_m, t_rule, t_inc, t_incFile, t_incStr
		t_c = readFile_(p_p)
		If IsN(t_c) Then
			Exit Function
		End If
		t_c = RegReplace(t_c, "<"&"%"&" *?@.*?%"&">", "")
		t_c = RegReplace(t_c, "(<"&"%"&"[^>]+?)(option +?explicit)([^>]*?%"&">)", "$1'$2$3")
		t_rule = "<!-- *?#include +?(file|virtual) *?= *?""??([^"":?*\f\n\r\t\v]+?)""?? *?-->"
		If RegTest(t_c, t_rule) Then
			Set t_inc = RegMatch(t_c,t_rule)
			For Each t_m In t_inc
				If LCase(t_m.SubMatches(0))="virtual" Then
					t_incFile = t_m.SubMatches(1)
				Else
					t_incFile = Mid(p_p,1,InstrRev(p_p, IIF(Instr(p_p,":")>0,"\","/"))) & t_m.SubMatches(1)
				End If
				t_incStr = incReadByFile_(t_incFile)
				t_c = Replace(t_c,t_m,t_incStr)
			Next
			Set t_inc = Nothing
		End If
		incReadByFile_ = t_c
	End Function
	
	'''由代码片段获取完整的include代码(包括内部再include)
	'p_p指定该代码片段应处在的文件夹路径
	'p_s:代码段
	'p_p:代码段应处在的文件夹路径
	Private Function incReadByCode_(Byval p_s, Byval p_p)
		Dim t_c, t_m, t_rule, t_inc, t_incFile, t_incStr
		t_c = p_s
		If IsN(t_c) Then
			Exit Function
		End If
		t_c = RegReplace(t_c, "<"&"%"&" *?@.*?%"&">", "")
		t_c = RegReplace(t_c, "(<"&"%"&"[^>]+?)(option +?explicit)([^>]*?%"&">)", "$1'$2$3")
		t_rule = "<!-- *?#include +?(file|virtual) *?= *?""??([^"":?*\f\n\r\t\v]+?)""?? *?-->"
		If RegTest(t_c,t_rule) Then
			Set t_inc = RegMatch(t_c,t_rule)
			For Each t_m In t_inc
				If LCase(t_m.SubMatches(0))="virtual" Then
					t_incFile = t_m.SubMatches(1)
				Else
					t_incFile = p_p & t_m.SubMatches(1)
				End If
				t_incStr = incReadByFile_(t_incFile)
				t_c = Replace(t_c,t_m,t_incStr)
			Next
			Set t_inc = Nothing
		End If
		incReadByCode_ = t_c
	End Function
	
	'''格式化include代码
	'p_s:要格式化的代码
	Private Function getIncCode_(Byval p_s)
		'Response.Write(p_s)
		'Response.End
		Dim t_ts, t_c, t_tc, t_sc, t_st, t_en
		'Unix到Dos
		'p_s = Replace(p_s, vbLf, vbCrLf)
		'格式化隔行/%/>/</%/这种情况,防止Select语句被非法阻断
		p_s = RegReplace(p_s, "%"&">[\n\s*\r]+<"&"%", vbCrLf)
		'Response.Write(p_s)
		'开始
		t_c = "" : t_st = 1 : t_en = Instr(p_s,"<"&"%") + 2
		t_sc = "Response.Write "
		While t_en > t_st + 1
			t_ts = Mid(p_s, t_st, t_en-t_st-2)
			t_st = Instr(t_en, p_s, "%"&">") + 2
			If Has(t_ts) Then
				t_ts = Replace(t_ts, """", """""")
				t_ts = Replace(t_ts, vbCrLf, """&vbCrLf&""")
				t_c = t_c & t_sc & """" & t_ts & """" & vbCrLf
			End If
			t_ts = Mid(p_s, t_en, t_st-t_en-2)
			t_tc = RegReplace(t_ts, "^\s*=\s*", t_sc) & vbCrLf
			t_c = t_c & t_tc
			t_en = Instr(t_st, p_s, "<"&"%") + 2
		Wend
		t_ts = Mid(p_s, t_st)
		If Has(t_ts) Then
			t_ts = Replace(t_ts, """", """""")
			t_ts = Replace(t_ts, vbcrlf, """&vbCrLf&""")
			t_c = t_c & t_sc & """" & t_ts & """" & vbCrLf
		End If
		'getIncCode_ = Core.RegReplace(t_c,"(\n\s*\r)+",vbCrLf)
		'消除空行
		getIncCode_ = RegReplace(t_c, "(\n\s*\r)+", "")
	End Function
	
	'''动态include，不含编译
	'p_p:文件路径
	Public Sub Include__(Byval p_p)
		'On Error Resume Next
		'Response.Write(p_p&"1`12`")
		'Response.Flush
		Call ExecuteGlobal(getIncCode_(incReadByFile_(p_p)))
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			Response.Write(getIncCode_(incReadByFile_(p_p)))
			Response.ENd
			Errc.Throw(21)
		End If
		Err.Clear()
	End Sub
	
	'''动态include,含编译
	'p_p:文件路径
	Public Sub Include(Byval p_p)
		'On Error Resume Next
		ExecuteGlobal(getIncCode_(incReadByFile_(p_p)))
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			Errc.Throw(21)
		End If
		'无出错后进行Include编译
		s_inccodepre = s_inccodepre & "<!--#include virtual=""" & p_p & """-->" & vbcrlf
		Err.Clear()
	End Sub
	
	'''获取格式化后的代码,用于进行ExecuteGlobal运行
	'p_s:要格式化的代码
	Private Function formatCode_(Byval p_s)
		formatCode_ = getIncCode_(incReadByCode_(p_s, ""))
	End Function
	
	'''运行原生意大利面条代码
	'伪装的公用方法
	'p_s:要运行的代码
	Public Sub Run__(Byval p_s)
		'On Error Resume Next
		'Response.Write(p_s)
		'Response.End
		'Response.Write(getIncCode_(incReadByCode_(p_s, p_folderPath)))
		'Response.Flush
		ExecuteGlobal(getIncCode_(incReadByCode_(p_s, "")))
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			'直接输出查看错误
			Response.Write(getIncCode_(incReadByCode_(p_s, "")))
			Response.End
			Response.Flush
			Errc.Throw(22)
		End If
		Err.Clear()
	End Sub
	
	'''使用内置类
	'''本处Set NoThing无需在程序中手动执行
	'使用核心机制后,内置类与ashapo低耦合,可以任意添加其他类
	'p_f:类名(去掉Class)
	Public Sub Use(Byval p_f)
		'On Error Resume Next
		Dim t_fp : t_fp = "/" & C_CoreFolder & "/Class/" & p_f & "_Class.asp"
		If isFile_(t_fp) Then
			Include__(t_fp)
			ExecuteGlobal("Dim " & p_f & " : Set " & p_f & " = New " & p_f & "Class")
		Else
			'出错处理
			Errc.Throw(23)
		End If
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			Errc.Throw(24)
		End If
		'添加析构
		'变更为Sa公有属性则在Ashapo类中进行析构
		addCodeFix_("Set " & p_f & " = Nothing")
		'无出错后进行Use编译
		s_inccodepre = s_inccodepre & "<!--#include virtual=""/" & C_CoreFolder & "/Class/" & p_f & "_Class.asp""-->" & vbcrlf
		s_inccodepre = s_inccodepre & "<" & "%" & "Dim " & p_f & " : Set " & p_f & " = New " & p_f & "Class" & "%" & ">" & vbcrlf
		'析构在Asp类中进行一次,生成缓存后手动析构
		s_inccodefix = "Set " & p_f & " = Nothing" & vbcrlf & s_inccodefix
		Err.Clear()
	End Sub
	
	'''伪继承
	'''多级继承的考虑
	'''本处Set NoThing应在生成的缓存文件中添加自动执行
	''伪继承文件名后缀和配置文件当前不关联,后期需要修改
	'p_f:Action类名(去掉Class)
	Public Sub Extends(Byval p_f)
		'On Error Resume Next
		Dim t_fp : t_fp = "/" & C_AppFolder & "/" & C_ActionFolder & "/" & p_f & ".class.asp"
		If isFile_(t_fp) Then
			Include__(t_fp)
			Dim t_a : t_a = Replace(p_f, "Action", "")
			ExecuteGlobal("Dim " & t_a & " : Set " & t_a & " = New " & p_f)
			'Response.Write(t_a&"111111111")
			'Response.Flush
			'Response.end
		Else
			'出错处理
			Errc.Throw(25)
		End If
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			Errc.Throw(26)
		End If
		'添加析构
		addCodeFix_("Set " & t_a & " = Nothing")
		'无出错后进行Extends编译
		Dim t_sp : t_sp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_extends/" & p_f & ".class.asp"
		Dim t_s : t_s = formatAction_(readFile_(t_fp))
		If isFile_(t_fp) Then
			If C_AppStatus = "default" Or C_AppStatus = "record" Then
				If Not createFile_(t_sp, t_s,0) Then
					Errc.Throw(41)
				End If
			End If
		Else
			'Extends文件不存在，抛出错误
			Errc.Throw(40)
		End If
		s_inccodepre = s_inccodepre & "<!--#include virtual=""" & t_sp & """-->" & vbcrlf
		s_inccodepre = s_inccodepre & "<" & Chr(37) & "Dim " & t_a & " : Set " & t_a & " = New " & p_f & Chr(37) & ">" & vbcrlf
		s_inccodefix = "Set " & t_a & " = Nothing" & vbcrlf & s_inccodefix
		Err.Clear()
	End Sub
	
	'''编译Action类文件,生成缓存
	'''编译处理包括:
	'''1.Asp.Extends,处理方法:改成在缓存文件include并进行实例化(set nothing的处理)
	'''2.Asp.Use,处理方法:改成在缓存文件include并进行实例化(set nothing的处理)
	'''3.Asp.Include,目前仅支持上下文无关include,且路径必须为绝对路径
	'''4.Asp.Model,处理方法:目前未启用
	'p_p:Action类文件路径
	Private Sub byAction_(Byval p_p)
		If C_AppStatus = "debug" Or C_AppStatus = "speed" Then
			Exit Sub
		End If
		Dim t_s : t_s = formatAction_(readFile_(p_p))
		Dim t_sp : t_sp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_action/" & Split(p_p, "/")(3) & "/" & Split(p_p, "/")(4)
		If Not createFile_(t_sp, t_s, 0) Then
			Errc.Throw(41)
		End If
	End Sub
	
	'''添加cache_page_list
	'p_p:缓存路径
	Private Sub addPageCache_(Byval p_p)
		Dim t_a,t_d,t_c : t_c = "%Ashapo_Cache_Page%"
		Dim t_k : t_k = "/" & C_DataFolder & "/" & C_CacheFolder & "/cache.lock"
		'Lock文件不见了,即缓存文件被清除了
		If Not isFile_(t_k) Then
			RemoveApp(t_c)
		End If
		If IsArray(GetApp(t_c)) Then
			If TypeName(GetApp(t_c)(0))="Dictionary" Then
				Set t_d = GetApp(t_c)(0)
				If Not t_d.Exists(p_p) Then
					t_d(p_p) = 1'其实只是要键值,赋值什么无所谓的
					'RemoveApp(t_c)
					t_a = Array(t_d)
					Call SetApp(t_c, t_a)
				End If
			Else
				Set t_d = Server.CreateObject(C_DicName)
				t_d(p_p) = 1
				t_a = Array(t_d)
				Call SetApp(t_c, t_a)
				If Not createFile_(t_k, "删除缓存请将该文件一并删除!",1) Then
					Errc.Throw(111)
				End If
			End If
		Else
			Set t_d = Server.CreateObject(C_DicName)
			t_d(p_p) = 1
			t_a = Array(t_d)
			Call SetApp(t_c, t_a)
			If Not createFile_(t_k, "删除缓存请将该文件一并删除!",1) Then
				Errc.Throw(111)
			End If
		End If
	End Sub
	
	'''生成缓存文件并运行结果
	'''该函数仅在生成时有效,且使用了ashapo核心fso
	'Display应针对不同运行模式生成不同的缓存文件
	'p_tp:对应的模板文件路径
	Public Sub Display(Byval p_tp)
		Dim t_v, t_r, t_i
		If Not p_tp= "" Then
			'变更Tpl路径
			s_vtp = p_tp
		End If
		'在这里不进行,因为删除缓存会导致Server.Transfer(错误)
		'If IsIn(s_vcp, Application("%Ashapo_Cache_Page%")) Then
		'	Server.Transfer(s_vcp)
		'	Exit Sub
		'End If
		If isFile_(s_vcp) Then
			'''直接运行代码
			addPageCache_(s_vcp)
			Server.Transfer(s_vcp)
			Exit Sub
		Else
			'''如果无缓存action类文件则进行编译建立
			byAction_(s_vfp)
			'''获取v代码
			If isFile_(s_vtp) Then
				t_v = readFile_(s_vtp)
				'''修改v代码,进行解析
				t_v = jx_(t_v)
			Else
				t_v = ""
			End If
			'本次运行意大利面条代码
			t_r = t_v
			'''修改v代码
			Dim t_vp : t_vp = ""	'v代码的首部添加字符
			'''装入s_vcodepre
			If Not Trim(s_vcodepre) = "" Then
				t_vp = "<" & Chr(37) & Trim(s_vcodepre) & Chr(37) & ">" & vbcrlf
			End If
			'''include所需代码
			'include底层设置
			t_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Conf/config.asp""-->" & vbcrlf
			'include用户设置
			Dim t_cfg : t_cfg = Array("config", "conn", "rule", s_nowG)
			For t_i = 0 To UBound(t_cfg)
				If isFile_("/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp") Then
					t_vp = t_vp & "<!--#include virtual=""/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp""-->" & vbcrlf
				End If
			Next
			'Dim t_cfg : t_cfg = Fso.List("/" & C_AppFolder & "/" & C_ConfFolder & "/", 1)
			'For t_i = 0 To UBound(t_cfg,2)
			'	t_vp = t_vp & "<!--#include virtual=" & Chr(34) & "/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(0,t_i) & Chr(34) & "-->" & vbcrlf
			'Next
			'include会话全局变量(废弃)
			't_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Conf/session.asp""-->" & vbcrlf
			'include底层函数(函数不分先后,但是是否应将comm.asp函数提前?)
			Dim t_cf : t_cf = dirList_("/" & C_CoreFolder & "/Common/", 1)
			For t_i = 0 To UBound(t_cf,2)
				t_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Common/" & t_cf(0,t_i) & """-->" & vbcrlf
			Next
			'include语言包
			t_vp = t_vp & ByLang__("") & vbcrlf
			'include Ashapo
			t_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Core/Ashapo.asp""-->" & vbcrlf
			'include用户函数
			Dim t_pf : t_pf = dirList_("/" & C_AppFolder & "/" & C_CommonFolder & "/", 1)
			For t_i = 0 To UBound(t_pf,2)
				t_vp = t_vp & "<!--#include virtual=""/" & C_AppFolder & "/" & C_CommonFolder & "/" & t_pf(0,t_i) & """-->" & vbcrlf
			Next
			'include use/Include/Extends
			t_vp = t_vp & s_inccodepre
			'response.Clear
			'Response.Write(s_inccodepre)
			'response.end
			'include Action类
			t_vp = t_vp & "<!--#include virtual=""/" & C_DataFolder & "/" & C_CacheFolder & "/_action/" & s_nowG & "/" & s_nowM & C_ActionSuf & ".asp""-->" & vbcrlf
			'实例化Action
			t_vp = t_vp & "<" & Chr(37) & "Dim " & s_nowM & " : Set " & s_nowM & " = New " & s_nowM & "Action : " & s_nowM & "." & s_nowA & "()" & Chr(37) & ">"
			'''修改v代码,include缓存c代码
			t_v = t_vp & t_v
			'''析构类
			t_v = t_v & "<" & Chr(37) & vbcrlf
			'use/Include/Extends先执行
			t_v = t_v & s_inccodefix
			'主体Action
			t_v = t_v & "Set " & s_nowM & " = Nothing" & vbcrlf
			t_v = t_v & "Set Sa = Nothing" & vbcrlf
			t_v = t_v & "Set Errc = Nothing" & vbcrlf
			t_v = t_v & Chr(37) & ">"
			't_v = Replace(t_v, "%" & "><" & "%" , "")
			'''删除多余空行
			's_regex.Pattern = "(\n\r)|(^\r)|(\n$)"
			's_regex.Pattern = "\n\s*\r"
			't_v = s_regex.Replace(t_v,"")
			s_regex.Pattern = "\n[\s|	]*\r"
			t_v = s_regex.Replace(t_v,"")
			'''保存修改后代码
			'Fso.FileBOM = "remove"
			Select Case Lcase(C_AppStatus)
			Case "default","record"
				If createFile_(s_vcp, t_v, 0) Then
					'更新cache_page_list
					addPageCache_(s_vcp)
				Else
					Errc.Throw(42)
				End If
			Case "speed"
				t_v = incReadByCode_(t_v,"")
				t_v = formatAction_(t_v)
				If createFile_(s_vcp, t_v, 1) Then
					'更新cache_page_list
					addPageCache_(s_vcp)
				Else
					Errc.Throw(42)
				End If
			End Select
			'Fso.FileBOM = "keep"
			'''结束后运行代码
			'Server.Transfer(v_cp)
			'使用Server.Transfer会导致动作二次运行,应考虑使用Asp.Run来直接运行本次解析后所得的意大利面条代码
			'使用Response.End可以阻止运行,且可以在init中加入默认Tpl.Show()动作
			Run__(t_r)
			Response.End
		End If
	End Sub
	
	'''输出默认模板
	Public Sub Show()
		Display("")
	End Sub
	
''''''''''''''''''''''''''''''''''''''''---------------''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''系统页面相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

	'''获取Success/Error页面意大利面条代码
	'模版读取顺序:
	'1.所在分组内的模板Public:Success
	'2.Public分组下的Success
	'3.主题下的Success文件
	'4.Ashapo核心Success.tpl
	'p_n:标识符(success/error)
	Private Function resultCode_(Byval p_n)
		Dim t_g : t_g = s_nowG
		Dim t_app : t_app = "%Ashapo_" & Ucase(Left(t_g,1)) & Lcase(Right(t_g, Len(t_g)-1)) & "_" & p_n & "_Code%"
		If Has(GetApp(t_app)) Then
			resultCode_ = GetApp(t_app)
		Else
			Dim t_fp : t_fp = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/" & t_g & "/public/" & p_n & C_TplExtSuf
			If Not isFile_(t_fp) Then
				t_fp = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/public/" & p_n & C_TplExtSuf
			End If
			If Not isFile_(t_fp) Then
				t_fp = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/" & p_n & C_TplExtSuf
			End If
			If Not isFile_(t_fp) Then
				t_fp = "/" & C_CoreFolder & "/Tpl/" & p_n & ".tpl"
			End If
			resultCode_ = formatCode_(jx_(readFile_(t_fp)))
			Call SetApp(t_app, resultCode_)
		End If
	End Function

	'''运行跳转页面代码
	'p_t:标识符(success/error)
	'p_m:显示的提示信息
	Private Sub resultRun_(Byval p_t, Byval p_m)
		On Error Resume Next
		Dim t_u : t_u = s_jumpUrl
		Dim t_m : t_m = p_m
		Select Case Lcase(p_t)
		Case "success"
			If s_jumpUrl = "" Then
				t_u = Request.ServerVariables ("HTTP_REFERER")
			End If
		Case "error"
			If s_jumpUrl = "" Then
				t_u = ""
			End If
		Case Else
			If s_jumpUrl = "" Then
				t_u = ""
			End If
		End Select
		If t_m = "" Then
			t_m = s_message
		End If
		If p_m <> "" Then
			s_message = p_m
		End If
		Assign("T_Title") : T_Title = s_msgTitle
		Assign("T_Message") : T_Message = t_m
		Assign("T_JumpUrl") : T_JumpUrl = t_u
		Assign("T_WaitSecond") : T_WaitSecond = s_waitSecond
		'Response.Write(resultCode_(p_t))
		'Response.End
		ExecuteGlobal(resultCode_(p_t))
		If Err.Number<>0 Then
			'抛出错误,Log信息收集
			'Response.Write(resultCode_(p_t))
			'Response.Write(Err.Number)
			'Response.End
			'Response.Flush
			Errc.Throw(22)
		End If
		Err.Clear()
	End Sub
	
	'''Success页面跳转
	'p_m:显示的提示信息
	Public Sub Success(Byval p_m)
		Call resultRun_("Success", p_m)
	End Sub
	
	'''Error页面跳转
	'p_m:显示的提示信息
	Public Sub [Error](Byval p_m)
		Call resultRun_("Error", p_m)
	End Sub
	
	'''Error页面跳转
	'Response.End
	'p_m:显示的提示信息
	Public Sub ErrorE(Byval p_m)
		Call resultRun_("Error", p_m)
		Response.End
	End Sub
	
	'''底层404、500的运行代码，不含环境变量，仅解析V代码
	'伪装的公用方法
	'p_n:标识符(404/500)
	Public Function SysRunCode__(Byval p_n)
		Dim t_p, t_v : t_v = ""
		t_p = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/" & p_n & C_TplExtSuf
		If Not isFile_(t_p) Then
			'内置的404/500模板
			t_p = "/" & C_CoreFolder & "/Tpl/" & p_n & ".tpl"
		End If
		t_v = readFile_(t_p)
		t_v = jx_(t_v)
		SysRunCode__ = t_v
	End Function
	
	'''系统底层模板是否存在，目前只有404或500(如果已存在返回true，否则进行建立，成功建立则返回true，否则返回false)
	'404为单独页面，505为include页面末端实现。
	'20131008改为在首次运行时统一建立404和505页面,必须保证本过程在模板解析之前运行
	'p_n:标识符(404/500)
	Public Function HasSysTpl__(Byval p_n)
		If Lcase(C_AppStatus)="debug" Then
			HasSysTpl__ = False
			Exit Function
		End If
		Dim t_cp : t_cp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_system/page_" & p_n & ".asp"
		If isFile_(t_cp) Then
			HasSysTpl__ = True
			Exit Function
		End If
		'当语言包无法生成成功时直接返回false
		'default/record模式下,语言包如果未生成直接返回false
		Dim t_alp : t_alp = "/" & C_AppFolder & "/" & C_LangFolder & "/"
		Dim t_clp : t_clp = "/" & C_CoreFolder & "/Lang/"
		Dim t_lcp : t_lcp = "/" & C_DataFolder & "/" & C_CacheFolder & "/_lang/"
		If IsIn(Lcase(C_AppStatus), Array("default", "record")) Then
			'底层lang
			Dim t_i,t_lf : t_lf = dirList_(t_clp, 1)
			For t_i = 0 To UBound(t_lf,2)
				If Not createFile_(t_lcp & "ashapo_" & nameOfFile_(t_lf(0,t_i)) & ".asp", lang_(t_clp & t_lf(0,t_i)), 0) Then
					HasSysTpl__ = False
					Exit Function
				End If
			Next
			'app各语言文件夹下common.ini
			t_lf = dirList_(t_alp, 2)
			For t_i = 0 To UBound(t_lf,2)
				If isFile_(t_alp & t_lf(0,t_i) & "/common.ini") Then
					If Not createFile_(t_lcp & t_lf(0,t_i) & "_common.asp", lang_(t_alp & t_lf(0,t_i) & "/common.ini"), 0) Then
						HasSysTpl__ = False
						Exit Function
					End If
				End If
			Next
			'入口文件
			If Not isFile_(t_lcp & "ashapo.asp") Then
				If Not createFile_(t_lcp & "ashapo.asp", ByLang__("outer"), 0) Then
					HasSysTpl__ = False
					Exit Function
				End If
			End If
		End If
		'Response.End
		Dim  t_v : t_v = SysRunCode__(p_n)
		Select Case Cstr(p_n)
		Case "404"
			'404要加载语言包和类、函数等
			'语言包文件生成时发生错误时，理论顺序是语言包生成失败开始走500错误，500错误文件生成不了则显示底层500错误
			'当404错误发生时，进入底层文件编译流程，其他文件编译失败进入500错误，500错误文件生成不了则显示底层500错误
			'语言包文件生成应该发生在404和500之前
			'''修改v代码
			Dim t_vp : t_vp = ""	'v代码的首部添加字符
			'''include所需代码
			'include底层设置
			t_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Conf/config.asp""-->" & vbcrlf
			'include用户设置
			't_vp = t_vp & "<!--#include virtual=""/" & C_AppFolder & "/" & C_ConfFolder & "/config.asp""-->" & vbcrlf
			Dim t_cfg : t_cfg = Array("config", "conn", "rule", i_g)
			For t_i = 0 To UBound(t_cfg)
				If isFile_("/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp") Then
					t_vp = t_vp & "<!--#include virtual=""/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp""-->" & vbcrlf
				End If
			Next
			'include底层函数
			Dim t_cf : t_cf = dirList_("/" & C_CoreFolder & "/Common/", 1)
			For i = 0 To UBound(t_cf,2)
				t_vp = t_vp & "<!--#include virtual=" & Chr(34) & "/" & C_CoreFolder & "/Common/" & t_cf(0,i) & Chr(34) & "-->" & vbcrlf
			Next
			t_vp = t_vp & ByLang__("run") & vbcrlf
			'include会话全局变量(废弃)
			't_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Conf/session.asp""-->" & vbcrlf
			'include Ashapo
			t_vp = t_vp & "<!--#include virtual=""/" & C_CoreFolder & "/Core/Ashapo.asp""-->" & vbcrlf
			'include用户函数
			Dim t_pflist : t_pflist = dirList_("/" & C_AppFolder & "/" & C_CommonFolder & "/", 1)
			For i = 0 To UBound(t_pflist,2)
				t_vp = t_vp & "<!--#include virtual=""/" & C_AppFolder & "/" & C_CommonFolder & "/" & t_pflist(0,i) & """-->" & vbcrlf
			Next
			t_vp = t_vp & "<" & Chr(37) & vbcrlf
			'状态
			t_vp = t_vp & "Response.Clear" & vbcrlf
			t_vp = t_vp & "Response.Status = ""404 Not Found""" & vbcrlf
			t_vp = t_vp & Chr(37) & ">"
			'''修改v代码,include缓存c代码
			t_v = t_vp & t_v
			'''析构类
			t_v = t_v & "<" & Chr(37) & vbcrlf
			t_v = t_v & "Set Sa = Nothing" & vbcrlf
			t_v = t_v & "Set Errc = Nothing" & vbcrlf
			t_v = t_v & Chr(37) & ">"
			't_v = Replace(t_v, "%" & "><" & "%" , "")
			'''删除多余空行
			's_regex.Pattern = "(\n\r)|(^\r)|(\n$)"
			s_regex.Pattern = "\n\s*\r"
			t_v = s_regex.Replace(t_v,"")
			Select Case Lcase(C_AppStatus)
			Case "default","record"
				HasSysTpl__ = createFile_(t_cp, t_v, 0)
			Case "speed"
				HasSysTpl__ = createFile_(t_cp, t_v, 1)
			End Select
		Case "500"
			'500采用include所以不用加载任何东西，但是该500页面无法单独运行
			'Do Nothing
			Select Case Lcase(C_AppStatus)
			Case "default","record"
				HasSysTpl__ = createFile_(t_cp, t_v, 0)
			Case "speed"
				HasSysTpl__ = createFile_(t_cp, t_v, 1)
			End Select
		Case ""
			'应该还是要生成一个可以直接运行的500页面
			'这个页面可以单独运行来作为系统的500页面，保持体验一致
		Case Else
			'目前不支持其他类型
			HasSysTpl__ = False
			Exit Function
		End Select
	End Function
	
''''''''''''''''''''''''''''''''''''''''---------------''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''流程处理相关'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	'''在生成缓存前时必须更新MAL值,缓存页面已做好更新处理
	Private Sub incAppConf_()
		Dim t_i,t_cfg : t_cfg = Array("config","conn","rule",s_nowG)
		'载入分组配置
		For t_i = 0 To UBound(t_cfg)
			If isFile_("/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp") Then
				Include__("/" & C_AppFolder & "/" & C_ConfFolder & "/" & t_cfg(t_i) & ".asp")
			End If
		Next
		'更新s_vfp/s_ccp/s_vtp
		s_vfp = "/" & C_AppFolder & "/" & C_ActionFolder & "/" & s_nowG & "/" & s_nowM & C_ActionSuf & ".asp"
		s_ccp = "/" & C_DataFolder & "/" & C_CacheFolder & "/" & s_nowG & "/" & s_nowM & C_ActionSuf & ".asp"
		s_vtp = "/" & C_AppFolder & "/" & C_TplFolder & "/" & s_nowT & "/" & s_nowG & "/" & s_nowM & "/" & s_nowA & C_TplExtSuf
	End Sub
	
	'''ashapo入口
	Public Sub Init__()
		If isFile_(s_vcp) Then
			'可运行缓存文件,直接执行该文件
			addPageCache_(s_vcp)
			Server.Transfer(s_vcp)
		Else
			incAppConf_()
			'开始编译
			'''加载编译语言包
			'Response.Write("123")
			'Response.Flush
			Run__(ByLang__(""))
			'Response.Write("123")
			'Response.Flush
			'''加载底层函数
			Dim t_i,t_cf : t_cf = dirList_("/" & C_CoreFolder & "/Common/", 1)
			For t_i = 0 To UBound(t_cf, 2)
				If t_cf(0, i) <> "common.asp" Then
					Include__("/" & C_CoreFolder & "/Common/" & t_cf(0, t_i))
				End If
			Next
			'''加载用户函数
			Dim t_pf : t_pf = dirList_("/" & C_AppFolder & "/" & C_CommonFolder & "/", 1)
			For t_i = 0 To UBound(t_pf,2)
				Include__("/" & C_AppFolder & "/" & C_CommonFolder & "/" & t_pf(0,t_i))
			Next
			'可运行缓存文件,运行该Action类(对应函数)一次,如带Display过程,则缓存文件已自动生成
			If isFile_(s_vfp) Then
				'''进行函数判断,如果无该函数,则出现404错误
				Dim t_cc : t_cc = readFile_(s_vfp)
				If hasFunSub_(s_nowA, t_cc) Then
					Include__(s_vfp)
				Else
					'运行到这步时性能已经完全下降
					'Response.Write("123")
					'Response.Flush
					Errc.Show404()
					'Response.Write("Found 404 Err On Asp.Include Ccode")
					'Response.End
				End If
			Else
				'Response.Write("Found Err On Asp.Include Ccode")
				'Response.End
				'运行到这步时性能已经完全下降
				Errc.Show404()
			End If
			'Response.Clear
			'Tpl.initIncPre_()
			ExecuteGlobal("Dim " & s_nowM & " : Set " & s_nowM & " = New " & s_nowM & "Action")
			ExecuteGlobal(s_nowM & "." & s_nowA & "()")
			'运行一次默认Tpl.Show来保证直接输出,可能被阻断而不需运行
			Show()
		End If
	End Sub
''''''''''''''''''''''''''''''''''''''''---------------''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Class
'要先实例化Errc
Dim Errc : Set Errc = New ErrcClass
'实例化Ashapo
Dim Sa : Set Sa = New AshapoClass
%>